package com.example.controller;


import cn.hutool.core.date.DateUtil;
import com.example.base.Enum.AdoptStatusEnum;
import com.example.base.response.Result;
import com.example.entity.*;
import com.example.service.AdoptService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "宠物领养管理")
@CrossOrigin
@RestController
@RequestMapping("/adopt")
public class adoptController {
    @Autowired
    private AdoptService adoptService;

    @PostMapping
    public Result update(@RequestBody Adopt adopt) {

        adoptService.update(adopt);
        return Result.success();
    }


    @PostMapping("/add")
    public Result save(@RequestBody Adopt adopt) {
        adopt.setTime(DateUtil.now());
        adopt.setStatus(AdoptStatusEnum.ADOPT_YES.status);
        adoptService.add(adopt);
        return Result.success();
    }


    @GetMapping("/search")
    public Result findBySearch(Params params) {
        PageInfo<Adopt> info = adoptService.findBySearch(params);
        return Result.success(info);
    }


}
